<template>
    <div class="type-icon-list">
        <div class="item-nav" v-if="detail.label">
            <div class="nav-left"></div>
            <div class="nav-center">{{detail.label}}</div>
            <div class="nav-right">更多</div>
        </div>
        <div class="box">
            <div class="item-box" :style="{'width': list.length * 82 + 'px'}">
                <div class="item" v-for="(item, index) in list" :key="index">
                    <div class="item-icon">
                        <img :src="item.appIcon" alt="">
                    </div>
                    <div class="item-title">{{item.appName}}</div>
                    <div class="item-score">
                        <div class="score-icon"></div>
                        <div class="score-num">{{item.appScore}}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    // icon陈列表 7000
    name: 'model7000',
    props: ['data'],
    data () {
        return {
            detail: {
                label: '',
                limit: 3,
                elements: [
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    },
                    {
                        appIcon: '',
                        appName: '游戏名称',
                        appScore: 9.9
                    }
                ]
            }
        }
    },
    created () {
        if (this.data) {
            this.detail.label = this.data.label
            this.detail.limit = this.data.limit
        }
        if (this.data && this.data.elements && this.data.elements.length) {
            this.detail = this.data
        }
    },
    watch: {
        data: {
            handler: function (val) {
                if (val) {
                    this.detail.label = val.label
                    this.detail.limit = val.limit
                }
                if (val && val.elements && val.elements.length) {
                    this.detail = val
                }
            },
            deep: true
        }
    },
    computed: {
        list () {
            let arr = this.detail.elements.slice(0, this.detail.limit)
            return arr
        }
    }
}
</script>

<style lang="scss">
    .type-icon-list {
        padding: 18px 0px 20px;
        border-bottom: 1px solid rgba(228,228,228,1);
        .item-nav {
            display: flex;
            height: 16px;
            align-items: center;
            padding: 0 16px;
            margin-bottom: 12px;
            .nav-left {
                width:4px;
                height:16px;
                background:rgba(0,191,60,1);
                border-radius:3px;
                margin-right: 8px;
            }
            .nav-center {
                flex: 1;
                font-size:16px;
                font-family:SourceHanSansCN-Medium,SourceHanSansCN;
                font-weight:500;
                color:rgba(28,32,44,1);
            }
            .nav-right {
                margin-right: 4px;
                display: flex;
                align-items: center;
                font-size:12px;
                font-family:SourceHanSansCN-Normal,SourceHanSansCN;
                font-weight:400;
                cursor: pointer;
                color:rgba(28,32,44,0.6);
                &::after {
                    content: '';
                    width: 7px;
                    height: 7px;
                    margin-left: 4px;
                    border-right: 2px solid #1C202C;
                    border-bottom: 2px solid #1C202C;
                    transform: rotate(-45deg);
                }
            }

        }
        .box {
            padding-left: 16px;
            overflow-x: scroll;
            .item-box {
                display: flex;
                .item {
                    width: 82px;
                    .item-icon {
                        width: 68px;
                        height: 68px;
                        border-radius:15px;
                        overflow: hidden;
                        background-color:rgb(246, 197, 68);
                        > img {
                            width: 100%;
                            height: 100%;
                        }
                    }
                    .item-title {
                        margin-top: 8px;
                        height: 36px;
                        width: 68px;
                        font-size:12px;
                        font-family:SourceHanSansCN-Regular,SourceHanSansCN;
                        font-weight:400;
                        color:rgba(28,32,44,1);
                        line-height:14px;
                    }
                    .item-score {
                        display: flex;
                        align-items: center;
                        .score-icon {
                            width: 10px;
                            height: 12px;
                            background-image: url('./img/score-icon.png');
                            background-size: 100% 100%;
                            margin-right: 4px;
                        }
                        .score-num {
                            font-size:12px;
                            font-family:Roboto-BoldItalic,Roboto;
                            font-weight:normal;
                            color:rgba(0,191,60,1);
                        }
                    }
                }
            }
        }
    }
</style>
